Service¶
unique_toolkit.agentic_table.service.AgenticTableService
¶
Provides methods to interact with the Agentic Table.
Attributes:
| Name | Type | Description |
|---|---|---|
#event |
ChatEvent
|
The ChatEvent object. |
logger |
Optional[Logger]
|
The logger object. Defaults to None. |
Source code in unique_toolkit/agentic_table/service.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
deregister_agent()
async
¶
Deregisters the agent for the Agentic Table by updating the sheet state to IDLE.
Raises:
| Type | Description |
|---|---|
LockedAgenticTableError
|
If the Agentic Table is busy. |
Source code in unique_toolkit/agentic_table/service.py
185 186 187 188 189 190 191 192 193 194 195 196 197 | |
get_cell(row, column, include_row_metadata=True)
async
¶
Gets the value of a cell in the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The row index. |
required |
column
|
int
|
The column index. |
required |
include_row_metadata
|
bool
|
Whether to include the row metadata. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MagicTableCell |
MagicTableCell
|
The MagicTableCell object. |
Source code in unique_toolkit/agentic_table/service.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
get_num_rows()
async
¶
Gets the number of rows in the Agentic Table.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of rows in the Agentic Table. |
Source code in unique_toolkit/agentic_table/service.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
get_sheet(start_row=0, end_row=None, batch_size=100, include_log_history=False, include_cell_meta_data=False, include_row_metadata=False)
async
¶
Gets the sheet data from the Agentic Table paginated by batch_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_row
|
int
|
The start row (inclusive). |
0
|
end_row
|
int | None
|
The end row (not inclusive). |
None
|
batch_size
|
int
|
The batch size. |
100
|
include_log_history
|
bool
|
Whether to include the log history. |
False
|
include_cell_meta_data
|
bool
|
Whether to include the cell metadata (renderer, selection, agreement status). |
False
|
include_row_metadata
|
bool
|
Whether to include the row metadata (key value pairs). |
False
|
Source code in unique_toolkit/agentic_table/service.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
get_sheet_metadata()
async
¶
Gets the sheet metadata from the Agentic Table.
Returns:
| Type | Description |
|---|---|
list[RowMetadataEntry]
|
list[RowMetadataEntry]: The sheet metadata. |
Source code in unique_toolkit/agentic_table/service.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
register_agent()
async
¶
Registers the agent for the Agentic Table by updating the sheet state to PROCESSING.
Raises:
| Type | Description |
|---|---|
LockedAgenticTableError
|
If the Agentic Table is busy. |
Source code in unique_toolkit/agentic_table/service.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
set_activity(text, activity, status=ActivityStatus.IN_PROGRESS)
async
¶
Sets the activity of the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activity
|
str
|
The activity to set. |
required |
Source code in unique_toolkit/agentic_table/service.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
set_artifact(artifact_type, content_id, mime_type, name)
async
¶
Upload/set report files to the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_type
|
ArtifactType
|
The type of artifact to set. |
required |
content_id
|
str
|
The content ID of the artifact. |
required |
mime_type
|
str
|
The MIME type of the artifact. |
required |
name
|
str
|
The name of the artifact. |
required |
Source code in unique_toolkit/agentic_table/service.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
set_cell(row, column, text, log_entries=None)
async
¶
Sets the value of a cell in the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The row index. |
required |
column
|
int
|
The column index. |
required |
text
|
str
|
The text to set. |
required |
log_entries
|
Optional[list[LogEntry]]
|
The log entries to set. |
None
|
Source code in unique_toolkit/agentic_table/service.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
set_cell_metadata(row, column, selected=None, selection_method=None, agreement_status=None)
async
¶
Sets the cell metadata for the Agentic Table. NOTE: This is not to be confused with the sheet metadata and is associated rather with selection and agreement status, row locking etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The row index. |
required |
column
|
int
|
The column index. |
required |
selected
|
bool | None
|
Whether the cell is selected. |
None
|
selection_method
|
SelectionMethod | None
|
The method of selection. |
None
|
agreement_status
|
AgreementStatus | None
|
The agreement status. |
None
|
Source code in unique_toolkit/agentic_table/service.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
set_column_style(column, width=None, cell_renderer=None, filter=None, editable=None)
async
¶
Sets the style of a column in the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
int
|
The column index. |
required |
width
|
int | None
|
The width of the column. Defaults to None. |
None
|
cell_renderer
|
CellRenderer | None
|
The cell renderer of the column. Defaults to None. |
None
|
filter
|
FilterComponents | None
|
The filter of the column. Defaults to None. |
None
|
editable
|
bool | None
|
Whether the column is editable. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the column style is not set. |
Source code in unique_toolkit/agentic_table/service.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
set_multiple_cells(cells, batch_size=4000)
async
¶
Sets the values of multiple cells in the Agentic Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
list[MagicTableCell]
|
The cells to set sorted by row and column. |
required |
batch_size
|
int
|
Number of cells to set in a single request. |
4000
|
Source code in unique_toolkit/agentic_table/service.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
update_row_verification_status(row_orders, status)
async
¶
Update the verification status of multiple rows at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_orders
|
list[int]
|
The row indexes to update. |
required |
status
|
RowVerificationStatus
|
The verification status to set. |
required |
Source code in unique_toolkit/agentic_table/service.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
Schemas¶
Event¶
The primary event type is MagicTableEvent.
unique_toolkit.agentic_table.schemas.MagicTableEvent
¶
Bases: ChatEvent
Source code in unique_toolkit/agentic_table/schemas.py
222 223 224 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
get_initial_debug_info()
¶
Get the debug information for the chat event
Source code in unique_toolkit/app/schemas.py
261 262 263 264 265 266 267 268 269 270 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
Event Payload Schemas¶
All event payloads inherit from the MagicTableBasePayload schema.
unique_toolkit.agentic_table.schemas.MagicTableBasePayload
¶
Bases: BaseModel, Generic[A, T]
Source code in unique_toolkit/agentic_table/schemas.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
The following payload schemas correspond to the events listed above:
unique_toolkit.agentic_table.schemas.MagicTableUpdateCellPayload
¶
Bases: MagicTableBasePayload[Literal[UPDATE_CELL], DDMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
132 133 134 135 136 137 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableAddMetadataPayload
¶
Bases: MagicTableBasePayload[Literal[ADD_META_DATA], DDMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
127 128 129 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableGenerateArtifactPayload
¶
Bases: MagicTableBasePayload[Literal[GENERATE_ARTIFACT], BaseMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
151 152 153 154 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableSheetCompletedPayload
¶
Bases: MagicTableBasePayload[Literal[SHEET_COMPLETED], SheetCompletedMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
176 177 178 179 180 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableLibrarySheetRowVerifiedPayload
¶
Bases: MagicTableBasePayload[Literal[LIBRARY_SHEET_ROW_VERIFIED], LibrarySheetRowVerifiedMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
199 200 201 202 203 204 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableSheetCreatedPayload
¶
Bases: MagicTableBasePayload[Literal[SHEET_CREATED], SheetCreatedMetadata]
Source code in unique_toolkit/agentic_table/schemas.py
186 187 188 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
Supporting Schemas¶
unique_toolkit.agentic_table.schemas.BaseMetadata
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.DDMetadata
¶
Bases: BaseMetadata
Source code in unique_toolkit/agentic_table/schemas.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.SheetCompletedMetadata
¶
Bases: BaseMetadata
Source code in unique_toolkit/agentic_table/schemas.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.SheetCreatedMetadata
¶
Bases: BaseMetadata
Source code in unique_toolkit/agentic_table/schemas.py
183 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.LibrarySheetRowVerifiedMetadata
¶
Bases: BaseMetadata
Source code in unique_toolkit/agentic_table/schemas.py
194 195 196 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.ArtifactData
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
146 147 148 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.ArtifactType
¶
Bases: StrEnum
Source code in unique_toolkit/agentic_table/schemas.py
140 141 142 143 | |
unique_toolkit.agentic_table.schemas.MagicTableCell
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.MagicTableSheet
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.LogEntry
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.LogDetail
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
227 228 229 230 231 232 233 234 235 236 237 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
unique_toolkit.agentic_table.schemas.RowMetadataEntry
¶
Bases: BaseModel
Source code in unique_toolkit/agentic_table/schemas.py
64 65 66 67 68 69 70 71 72 | |
__class_vars__
class-attribute
¶
The names of the class variables defined on the model.
__private_attributes__
class-attribute
¶
Metadata about the private attributes of the model.
__pydantic_complete__ = False
class-attribute
¶
Whether model building is completed, or if there are still undefined fields.
__pydantic_computed_fields__
class-attribute
¶
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
__pydantic_core_schema__
class-attribute
¶
The core schema of the model.
__pydantic_custom_init__
class-attribute
¶
Whether the model has a custom __init__ method.
__pydantic_decorators__ = _decorators.DecoratorInfos()
class-attribute
¶
Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
__pydantic_extra__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
__pydantic_fields__
class-attribute
¶
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
__pydantic_fields_set__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
The names of fields explicitly set during instantiation.
__pydantic_generic_metadata__
class-attribute
¶
Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__ = None
class-attribute
¶
Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
class-attribute
¶
The name of the post-init method for the model, if defined.
__pydantic_private__ = _model_construction.NoInitField(init=False)
class-attribute
instance-attribute
¶
Values of private attributes set on the model instance.
__pydantic_root_model__ = False
class-attribute
¶
Whether the model is a [RootModel][pydantic.root_model.RootModel].
__pydantic_serializer__
class-attribute
¶
The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_setattr_handlers__
class-attribute
¶
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
__pydantic_validator__
class-attribute
¶
The pydantic-core SchemaValidator used to validate instances of the model.
__signature__
class-attribute
¶
The synthesized __init__ [Signature][inspect.Signature] of the model.
model_extra
property
¶
Get extra fields set during validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary of extra fields, or |
model_fields_set
property
¶
Returns the set of fields that have been explicitly set on this model instance.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of strings representing the fields that have been set, i.e. that were not filled from defaults. |
__copy__()
¶
Returns a shallow copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | |
__deepcopy__(memo=None)
¶
Returns a deep copy of the model.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
__get_pydantic_json_schema__(core_schema, handler)
classmethod
¶
Hook into generating the model's JSON schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_schema
|
CoreSchema
|
A |
required |
handler
|
GetJsonSchemaHandler
|
Call into Pydantic's internal JSON schema generation.
This will raise a |
required |
Returns:
| Type | Description |
|---|---|
JsonSchemaValue
|
A JSON schema, as a Python object. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
__init__(**data)
¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
__init_subclass__(**kwargs)
¶
This signature is included purely to help type-checkers check arguments to class declaration, which provides a way to conveniently set model_config key/value pairs.
from pydantic import BaseModel
class MyModel(BaseModel, extra='allow'): ...
However, this may be deceiving, since the actual calls to __init_subclass__ will not receive any
of the config arguments, and will only receive any keyword arguments passed during class initialization
that are not expected keys in ConfigDict. (This is due to the way ModelMetaclass.__new__ works.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Unpack[ConfigDict]
|
Keyword arguments passed to the class definition, which set model_config |
{}
|
Note
You may want to override __pydantic_init_subclass__ instead, which behaves similarly but is called
after the class is fully initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | |
__iter__()
¶
So dict(model) works.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1229 1230 1231 1232 1233 1234 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass
only after basic class initialization is complete. In particular, attributes like model_fields will
be present when this is called, but forward annotations are not guaranteed to be resolved yet,
meaning that creating an instance of the class may fail.
This is necessary because __init_subclass__ will always be called by type.__new__,
and it would require a prohibitively large refactor to the ModelMetaclass to ensure that
type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely,
any kwargs passed to the class definition that aren't used internally by Pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Any keyword arguments passed to the class definition that aren't used internally by Pydantic. |
{}
|
Note
You may want to override __pydantic_on_complete__()
instead, which is called once the class and its fields are fully initialized and ready for validation.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
__pydantic_on_complete__()
classmethod
¶
This is called once the class and its fields are fully initialized and ready to be used.
This typically happens when the class is created (just before
__pydantic_init_subclass__() is called on the superclass),
except when forward annotations are used that could not immediately be resolved.
In that case, it will be called later, when the model is rebuilt automatically or explicitly using
model_rebuild().
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
877 878 879 880 881 882 883 884 885 886 | |
copy(*, include=None, exclude=None, update=None, deep=False)
¶
Returns a copy of the model.
Deprecated
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
data = self.model_dump(include=include, exclude=exclude, round_trip=True)
data = {**data, **(update or {})}
copied = self.model_validate(data)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to include in the copied model. |
None
|
exclude
|
AbstractSetIntStr | MappingIntStrAny | None
|
Optional set or mapping specifying which fields to exclude in the copied model. |
None
|
update
|
Dict[str, Any] | None
|
Optional dictionary of field-value pairs to override field values in the copied model. |
None
|
deep
|
bool
|
If True, the values of fields that are Pydantic models will be deep-copied. |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
A copy of the model with included, excluded and updated fields as specified. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
model_computed_fields()
classmethod
¶
A mapping of computed field names to their respective [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
273 274 275 276 277 278 279 280 281 282 | |
model_construct(_fields_set=None, **values)
classmethod
¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance's __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_fields_set
|
set[str] | None
|
A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [ |
None
|
values
|
Any
|
Trusted or pre-validated data dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of the |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
model_copy(*, update=None, deep=False)
¶
Usage Documentation
Returns a copy of the model.
Note
The underlying instance's [__dict__][object.__dict__] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data. |
None
|
deep
|
bool
|
Set to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
New model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['json', 'python'] | str
|
The mode in which |
'python'
|
include
|
IncEx | None
|
A set of fields to include in the output. |
None
|
exclude
|
IncEx | None
|
A set of fields to exclude from the output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias in the dictionary key if defined. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False)
¶
Usage Documentation
Generates a JSON representation of the model using Pydantic's to_json method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indent
|
int | None
|
Indentation to use in the JSON output. If None is passed, the output will be compact. |
None
|
ensure_ascii
|
bool
|
If |
False
|
include
|
IncEx | None
|
Field(s) to include in the JSON output. |
None
|
exclude
|
IncEx | None
|
Field(s) to exclude from the JSON output. |
None
|
context
|
Any | None
|
Additional context to pass to the serializer. |
None
|
by_alias
|
bool | None
|
Whether to serialize using field aliases. |
None
|
exclude_unset
|
bool
|
Whether to exclude fields that have not been explicitly set. |
False
|
exclude_defaults
|
bool
|
Whether to exclude fields that are set to their default value. |
False
|
exclude_none
|
bool
|
Whether to exclude fields that have a value of |
False
|
exclude_computed_fields
|
bool
|
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
|
False
|
round_trip
|
bool
|
If True, dumped values should be valid as input for non-idempotent types such as Json[T]. |
False
|
warnings
|
bool | Literal['none', 'warn', 'error']
|
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [ |
True
|
fallback
|
Callable[[Any], Any] | None
|
A function to call when an unknown value is encountered. If not provided,
a [ |
None
|
serialize_as_any
|
bool
|
Whether to serialize fields with duck-typing serialization behavior. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
model_fields()
classmethod
¶
A mapping of field names to their respective [FieldInfo][pydantic.fields.FieldInfo] instances.
Warning
Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
262 263 264 265 266 267 268 269 270 271 | |
model_json_schema(by_alias=True, ref_template=DEFAULT_REF_TEMPLATE, schema_generator=GenerateJsonSchema, mode='validation', *, union_format='any_of')
classmethod
¶
Generates a JSON schema for a model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use attribute aliases or not. |
True
|
ref_template
|
str
|
The reference template. |
DEFAULT_REF_TEMPLATE
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
The format to use when combining schemas from unions together. Can be one of:
|
'any_of'
|
schema_generator
|
type[GenerateJsonSchema]
|
To override the logic used to generate the JSON schema, as a subclass of
|
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
The mode in which to generate the schema. |
'validation'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON schema for the given model class. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
model_parametrized_name(params)
classmethod
¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
tuple[type[Any], ...]
|
Tuple of types of the class. Given a generic class
|
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the new class where |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when trying to generate concrete names for non-generic models. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
model_post_init(context)
¶
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
612 613 614 615 | |
model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)
classmethod
¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Whether to force the rebuilding of the model schema, defaults to |
False
|
raise_errors
|
bool
|
Whether to raise errors, defaults to |
True
|
_parent_namespace_depth
|
int
|
The depth level of the parent namespace, defaults to 2. |
2
|
_types_namespace
|
MappingNamespace | None
|
The types namespace, defaults to |
None
|
Returns:
| Type | Description |
|---|---|
bool | None
|
Returns |
bool | None
|
If rebuilding was required, returns |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
Any | None
|
Additional context to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Usage Documentation
Validate the given JSON data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)
classmethod
¶
Validate the given object with string data against the Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object containing string data to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
extra
|
ExtraValues | None
|
Whether to ignore, allow, or forbid extra data during model validation.
See the [ |
None
|
context
|
Any | None
|
Extra variables to pass to the validator. |
None
|
by_alias
|
bool | None
|
Whether to use the field's alias when validating against the provided input data. |
None
|
by_name
|
bool | None
|
Whether to use the field's name when validating against the provided input data. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The validated Pydantic model. |
Source code in .venv/lib/python3.12/site-packages/pydantic/main.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
Exceptions¶
unique_toolkit.agentic_table.service.LockedAgenticTableError
¶
Bases: Exception
Source code in unique_toolkit/agentic_table/service.py
26 27 | |